package exam.db.dao;

import java.util.List;

import exam.db.entity.TExaminationEntity;
import exam.db.entity.name.TExaminationEntityNames;
import exam.driver.jdbc.StatementSql;
import exam.driver.jdbc.WhereComplex;

/**
 * <p>TExaminationDao</p>
 * <p>Thực thi các truy vấn cho TExaminationEntity</p>
 * @author PHONGTN
 * @version 19/4/2012
 */
public class TExaminationDao extends AbstractDao<TExaminationEntity>{
	/**
	 * Constructor
	 */
	public TExaminationDao() {
		super(TExaminationEntity.class);
	}
	/**
	 * selectAll
	 * @return
	 */
	public List<TExaminationEntity> selectAll() {
		return super.selectAll(
				TExaminationEntity.class,
				new StatementSql()
					.select()
					.from(TExaminationEntityNames.TABLE_NAME)
					.toString()
				);
	}
	/**
	 * selectByPk
	 * @param pk
	 * @return
	 */
	public TExaminationEntity selectByPk(Integer pk) {
		return super.selectByPk(
				TExaminationEntity.class,
				new StatementSql()
					.select()
					.from(TExaminationEntityNames.TABLE_NAME)
					.where(
						new WhereComplex()
							.eq(TExaminationEntityNames.EXAM_ID, pk))
					.toString());
	}
	/**
	 * deleteByPk
	 * @param arrayPk
	 * @return
	 */
	public List<Integer> deleteByPk(int[] arrayPk) {
		return super.deleteByPk(
				new StatementSql()
					.delete()
					.from(TExaminationEntityNames.TABLE_NAME)
					.where(
						new WhereComplex()
							.eq(TExaminationEntityNames.EXAM_ID))
					.toString(), arrayPk);
	}
	/**
	 * insertByFile
	 * @param user
	 * @return
	 */
	public int insertByFile(TExaminationEntity exam) {
		String sqlFile = "src/exam/db/dao/sql/TExaminationEntity_insert.sql";
		return super.insertBySqlFile(exam, sqlFile);
	}
	/**
	 * updateByFile:TUserDao
	 * @param params
	 * @return
	 */
	public int updateByFile(List<Object> params) {
		String sqlFile = "src/exam/db/dao/sql/TExaminationEntity_update.sql";
		return super.updateBySqlFile(sqlFile, params);
	}
}
